D:\git\skunkworks\herald-for-cpp\herald\include\herald\ble\ble_protocols.h
Line | Count | Source |
1 | | // Copyright 2021 Herald Project Contributors |
2 | | // SPDX-License-Identifier: Apache-2.0 |
3 | | // |
4 | | |
5 | | #ifndef HERALD_BLE_PROTOCOLS_H |
6 | | #define HERALD_BLE_PROTOCOLS_H |
7 | | |
8 | | #include "../datatype/target_identifier.h" |
9 | | #include "../engine/activities.h" |
10 | | |
11 | | namespace herald { |
12 | | namespace ble { |
13 | | |
14 | | using namespace herald::datatype; |
15 | | using namespace herald::engine; |
16 | | |
17 | | // using HeraldConnectionCallback = std::function<void(const TargetIdentifier& toTarget, bool connNowOpen)>; |
18 | | |
19 | | /** |
20 | | * The Herald protocols' low level activities. Implemented by each OS' provider |
21 | | */ |
22 | | class HeraldProtocolV1Provider { |
23 | | public: |
24 | 8 | HeraldProtocolV1Provider() = default; |
25 | 8 | virtual ~HeraldProtocolV1Provider() = default; |
26 | | |
27 | | // FOR STD::ASYNC platforms:- |
28 | | |
29 | | // /** Opens a new connection. Returns true if successful or already connected */ |
30 | | // virtual void openConnection(const TargetIdentifier& toTarget, const HeraldConnectionCallback& connCallback) = 0; |
31 | | // /** Closes a connection. Returns true if successful or already disconnected */ |
32 | | // virtual void closeConnection(const TargetIdentifier& toTarget, const HeraldConnectionCallback& connCallback) = 0; |
33 | | |
34 | | // virtual void serviceDiscovery(Activity, CompletionCallback) = 0; |
35 | | // virtual void readPayload(Activity, CompletionCallback) = 0; |
36 | | // virtual void immediateSend(Activity, CompletionCallback) = 0; |
37 | | // virtual void immediateSendAll(Activity, CompletionCallback) = 0; |
38 | | |
39 | | // FOR OTHER PLATFORMS:- |
40 | | |
41 | | /** Opens a new connection. Returns true if successful or already connected. Will cause scanning and advertising to stop. */ |
42 | | virtual bool openConnection(const TargetIdentifier& toTarget) = 0; |
43 | | /** Closes a connection. Returns true if successful or already disconnected */ |
44 | | virtual bool closeConnection(const TargetIdentifier& toTarget) = 0; |
45 | | |
46 | | /** Restart scanning and advertising (if they were previously doing so) **/ |
47 | | virtual void restartScanningAndAdvertising() = 0; |
48 | | |
49 | | virtual std::optional<Activity> serviceDiscovery(Activity) = 0; |
50 | | virtual std::optional<Activity> readPayload(Activity) = 0; |
51 | | // virtual std::optional<Activity> immediateSend(Activity) = 0; |
52 | | // virtual std::optional<Activity> immediateSendAll(Activity) = 0; |
53 | | }; |
54 | | |
55 | | } |
56 | | } |
57 | | |
58 | | #endif |